home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
U-Utilities
/
(c)u3.d64
/
file copy.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-11
|
5KB
|
203 lines
20 PRINT CHR$(147)
30 PRINT " SINGLE DRIVE FILE COPY"
35 PRINT"[159] ONE MOMENT PLEASE"
40 POKE 52,31:POKE 56,31:CLR
45 FOR I=0TO173
50 READ D:POKE 7936+I,D:NEXT
55 POKE785,0:POKE786,31
60 PL$=CHR$(19)
65 FORI=1TO24:PL$=PL$+CHR$(17):NEXT
70 FORI=1TO39:CL$=CL$+" ":NEXT
75 CL$=CL$+CHR$(13)+CL$+CHR$(13)
80 CL$=LEFT$(PL$,21)+CL$+CL$+"[145][145][145][145]"
83 SP$="[145] "
84 Z$=" "
85 OPEN 15,8,15:REM OPEN ERROR CHAN
90 GOTO 1000
100 :
110 REM READ THE DIRECTORY
130 POKE785,0:REM SELECT READ FUNCTION
140 PRINT#15,"I":OPEN 2,8,2,"$"
150 NB=USR(2):REM LOAD DIR INTO MEM
160 CLOSE 2:GOSUB 810:REM CHECK ERROR
170 RETURN
200 :
210 REM DISPLAY DISK NAME
230 POKE 785,6:REM SELECT FETCH CHAR
235 PRINT CHR$(147)
240 PRINT LEFT$(PL$,3);CHR$(18);
250 FORK=142TO169
260 PRINT CHR$(USR(K));:NEXT
270 PRINT CHR$(146)
280 RETURN
300 :
310 REM PRINT DIRECTORY ENTRY DE
330 POKE785,6:REM SELECT FETCH CHAR 340 IX=(DE-1)*32+254-INT((DE-1)/8)*2
340 IX=(DE-1)*32+254-INT((DE-1)/8)*2
345 IF USR(IX)<128 THEN RETURN
350 TY=USR(IX)-128:IF TY=0 OR TY>3 THEN RETURN
360 FOR K=IX+3 TO IX+18
370 PRINT CHR$(USR(K));
380 NEXT:PRINT TAB(16);",";
390 PRINT MID$("SPU",TY,1):RETURN
400 :
410 REM GET DESTINATION DISK
430 PRINT CL$;
440 PRINT "[159] INSERT DESTINATION DISK[154]"
450 MS$=" PRESS RETURN[146] WHEN READY"
455 NL=1
460 GOSUB5000
480 IFDM$<>CHR$(13)GOTO460
490 PRINT#15,"I":RETURN
500 :
510 REM GET A FILE TO COPY
530 PRINT CL$;:IFEN=63GOTO580
560 NM$="":EN=0:UE=0
565 PRINT"[159]ENTER FILE,TYPE. RETURN[146] SCROLLS DIR'Y[154]"
570 INPUTNM$,TY$:RETURN
580 PRINTCL$;"[159]THERE'S ALREADY A [154]";NM$
582 PRINT"[159]DO YOU WISH TO REPLACE?(Y/N)[154]"
583 GET RE$:IFRE$=""GOTO583
584 IFRE$="Y"THEN GOTO 6000
586 PRINT"[159]ENTER NEW NAME[154]";
590 EN=0:NM$="":INPUT NM$
595 RETURN
600 :
610 REM READ THE FILE
630 POKE785,0:REM SELECT READ FUNCTION
640 OPEN 2,8,2,NM$+","+TY$+",R"
650 GOSUB900:IFEN<>0 THEN CLOSE2:RETURN
660 NB=USR(2):REM READ THE FILE
670 CLOSE 2:GOSUB 800:REM CHECK RESULTS
680 RETURN
700 :
710 REM WRITE THE FILE
730 POKE785,3:REM SELECT WRITE FUNCTION
740 OPEN 2,8,2,NM$+","+TY$+",W"
750 GOSUB900:IFEN<>0 THEN CLOSE2:RETURN
760 NB=USR(2):REM WRITE THE BYTES
770 CLOSE2:GOSUB 800:REM CHECK RESULTS
779 CLOSE2:GOSUB 800:REM CHECK RESULTS
780 RETURN
800 :
810 REM CHECK USR() RETURN VALUE
830 NB=NB-(NB<0)*65536
840 IFNB<61440 THEN UE=0:RETURN
850 IFNB=61440 THENUE=128:RETURN
860 PRINTCL$
870 IF PEEK(785)=0 THEN PRINT"READ"
880 IF PEEK(785)=3 THEN PRINT"WRITE"
890 PRINT" ERROR #";NB-61440:END
900 :
910 REM REAFD ERROR CHANNEL
940 INPUT#15,EN,EM$,ET,ES
950 IFEN=0OREN=62OREN=63 THEN RETURN
960 CLOSE 15:PRINTCL$;
970 PRINT "DISK ERROR #";EN
980 PRINT LEFT$(PL$,22);EM$:END
1000 :
1010 REM MAIN ROUTINE
1030 PRINT CHR$(147);:REM CLEAR SCREEN
1035 PRINT""
1040 PRINT"[159] INSERT SOURCE DISK[154]"
1042 MS$=" PRESS RETURN[146] WHEN READY"
1043 NL=3
1044 GOSUB5000
1046 IF DM$<>CHR$(13)THEN 1044
1050 PRINT:PRINTTAB(10);"[158]READING DIRECTORY";"[154]"
1060 GOSUB 110:REM READ THE DIRECTORY
1070 GOSUB 210:REM DISPLAY TITLE
1080 NS=INT((NB+1)/254)
1090 IFNS=1GOTO5000:REM NO FILES
1100 DS=1
1110 IF NS<=DS THEN DS=1:REM START OVER
1120 PRINT LEFT$(PL$,4);
1130 BE=(DS-1)*8+1:LE=BE+15
1140 IF DS+1=NS THEN LE=BE+8
1150 FOR DE=BE TOLE
1160 GOSUB 300:NEXT:REM DISPLAY FILES
1170 FORI=PEEK(214)TO20:REM CLEAR
1180 PRINT" "
1190 NEXT
1200 GOSUB 500:REM GET FILE NAME
1210 IF NM$="" THENDS=DS+2:GOTO1110
2000 :
2010 REM COPY THE FILE
2030 PRINTCL$;
2040 PRINT" [158]READING ";NM$;"[154]"
2050 GOSUB 600:REM READ THE FILE
2060 IF EN=62ORUE=128 GOTO1200
2070 BC=NB:REM SAVE COUNT
2080 GOSUB 400:REM GET DEST. DISK
2090 PRINT CL$;" [158]WRITING ";NM$;"[154]"
2100 GOSUB 700:REM WRITE THE FILE
2110 IF ENN=0 GOTO3000
2120 GOSUB 500:REM GET NEW FILE
2130 IF NM$<>"" GOTO2090
2140 PRINT CL$;"[159]FILE NOT COPIED[154]"
2150 GOTO3100
3000 :
3010 REM DISPLAY COMPLETION STATUS
3030 PRINT CL$;"[159]";
3040 IF NB<>BC GOTO3060
3050 PRINT"COPY SUCCESSFUL. ";:GOTO3070
3060 PRINT "ERROR. ONLY ";NB;" OUT ";
3070 PRINT BC;"BYTES COPIED."
3100 PRINT"PRESS ";CHR$(18);
3110 PRINT "RETURN";CHR$(146);
3120 PRINT" TO COPY ANOTHER FILE"
3125 PRINT"PRESS ANY OTHER KEY TO EXIT[154]"
3130 GET DM$:IF DM$=""GOTO3130
3140 IFDM$=CHR$(13) GOTO1000
3150 END
4000 :
4010 REM NO FILES ERROR HANDLING
4030 PRINT LEFT$(PL$,21);
4040 PRINT"NO FILES ON THIS DISK."
4050 PRINT"PRESS RETURN TO TRY ANOTHER DISK."
4070 GET DM$:IF DM$="" GOTO4070
4080 IF DM$=CHR$(13) GOTO1000
4090 END
5000 GET DM$:IFDM$<>""THEN RETURN
5005 PRINT MS$
5007 IFNL=1GOTO5060
5010 FOR I=1TO300:NEXT:PRINT SP$;"[145][145][145][145]"
5020 FORI=1TO200:NEXT
5040 GET DM$:IFDM$=""THEN5000
5050 RETURN
5060 FORI=1TO300:NEXT:PRINT SP$;"[145]"
5070 GOTO5020
6000 REM REPLACE SUBROUTINE
6005 PRINTCL$;
6010 PRINT#15,"S0:"+NM$:GOTO595
6040 REM RETURN
7000 PRINTCL$:FORI=1TO5:PRINTZ$:NEXT:PRINTCL$
7010 RETURN
10000 DATA 76,15,31,76,88,31,76,154
10010 DATA 31,108,3,0,108,5,0,32
10020 DATA 9,31,152,170,32,198,255,168
10030 DATA 176,57,169,0,133,251,169,32
10040 DATA 133,252,160,0,32,207,255,145
10050 DATA 251,230,251,208,2,230,252,165
10060 DATA 144,208,13,165,252,201,160,144
10070 DATA 235,32,204,255,160,0,240,19
10080 DATA 164,144,32,204,255,192,64,208
10090 DATA 10,164,251,165,252,56,233,32
10100 DATA 76,12,31,169,240,76,12,31
10110 DATA32,9,31,152,170,32,201,255
10120 DATA 168,176,240,165,251,141,174,31
10130 DATA165,252,141,175,31,169,0,133
10140 DATA 251,169,32,133,252,160,0,177
10150 DATA 251,32,210,255,164,144,208,20
10160 DATA230,251,208,2,230,252,165,252
10170 DATA 205,175,31,144,234,165,251,205
10180 DATA 174,31,144,227,32,204,255,76
10190 DATA 73,31,32,9,31,132,251,24
10200 DATA 105,32,133,252,160,0,177,251
10210 DATA 168,169,0,76,12,31
20100 TL=0:FORI=0TO173
20110 TL=TL+PEEK(7936+I)
20120 T=INT((I+1)/8)*8-1
20130 IF T=ITHENPRINTTL,:TL=0
20140 NEXT:PRINT TL